import deviceManager from '@ohos.distributedHardware.deviceManager';

const TAG: string = "BtConnector[RemoteDeviceListManager]";

export class RemoteDeviceListManager {
    private deviceManagerObj = null;

    constructor(){
        console.log(`${TAG} constructor`);
        deviceManager.createDeviceManager("com.ohos.callui", (error, value) => {
            if (error) {
                console.error(`${TAG} createDeviceManager failed ${error}`);
                return;
            }
            this.deviceManagerObj = value;
            //this.registerDeviceListCallback_(callback);
            console.log(`${TAG} createDeviceManager callback returned, error=${error} value=${value}`);
        });
    }

    getList(): any {
        if (this.deviceManagerObj !== null) {
            let list = this.deviceManagerObj.getTrustedDeviceListSync();
            console.log(`${TAG} getTrustedDeviceListSync, deviceList=` + JSON.stringify(list));
            return list
        }
        return undefined
    }

}